<?php
/**
 * 
 * @authors yutent (yutent@doui.cc)
 * @date    2015-03-17 18:51:43
 *
 */

class Do_Log {
    

	private static $dir;
	private static $file;

	function __construct($log_file = 'error.log', $log_dir = '/'){

        self::$dir = ROOT . 'data/logs' . $log_dir;
    	self::$file = self::$dir . $log_file;

    	if (!is_dir(self::$dir)) {
	        @umask(0);
	        $res = @mkdir(self::$dir, 0755);
	        if ($res === FALSE) {
	        	D::log('创建目录' . self::$dir . '失败');
	            return; //创建日志目录失败
	        }
	    }
    }



    /**
     * [write 写入日志文件]
     * @param  [type] $err [要写入的日志]
     * 
     */
    function write($err){

	    $time = time_format() . ' ';

	    file_put_contents(self::$file, $time . $err . "\n", FILE_APPEND);
    }
}